Skip to content

Conversation

@DannyBurge
Copy link

No description provided.

Copy link
Contributor

@antonkazakov antonkazakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Привет. Поправь замечания, пожалуйста


@Inject
@ActivityContext
lateinit var activityContext: Context
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Его можно через requireContext запросить, не вижу смысла инжектить

lateinit var activityContext: Context

lateinit var fragmentProducerComponent: FragmentProducerComponent
private val colorGenerator = ColorGeneratorImpl()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А его как раз нужно инжектить во вьюмодель

@ActivityContext
lateinit var activityContext: Context

lateinit var fragmentProducerComponent: FragmentProducerComponent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем тебе ссылка на компонент на уровне класса?

): View? {
return inflater.inflate(R.layout.fragment_a, container, true)
val activityComponent = (requireActivity() as MainActivity).activityComponent
fragmentProducerComponent = DaggerFragmentProducerComponent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше его создавать в onCreate/onAttach, сейчас он будет пересоздаваться каждый раз когда фрагмент будет класться/доставаться из бекстека

import javax.inject.Provider


class FragmentReceiver : Fragment() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Аналогичные замечания

import javax.inject.Inject


@ActivityScope
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь не нужен скоуп

fun getFlow(): StateFlow<Int>
}

@ActivityScope
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь тоже. Скоуп нужен если ты будешь инжектить конкретно этот тип, а ты инжектишь IDataKeeper и биндишь его помечая скоупом в даггеровском модуле

fun inject(fragmentReceiver: FragmentReceiver)

@ApplicationContext
fun provideApplicationContext(): Context
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А зачем тебе провижен метод во фрагмент компоненте? Кто-то будет зависить от FragmentReceiverComponent ?

fun inject(fragmentProducer: FragmentProducer)

@ApplicationContext
fun provideApplicationContext(): Context
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Все эти провижен методы не нужны

lateinit var activityComponent: ActivityComponent

@Inject
lateinit var dataKeeper: Provider<IDataKeeper>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Разве он нужен здесь?

Copy link
Contributor

@antonkazakov antonkazakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants